
<!doctype html>
<html lang="en">
	<head>
		<title>three.js girlattack.js</title>

		<meta charset="utf-8">

		<meta name="viewport"
			content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

		<style>
		
body {
	font-family: Monospace;
	margin: 0px;
	overflow: hidden;
}
</style>

	</head>

	<body>
<?php
$cs = Yii::app ()->getClientScript (); 
$cs = Yii::app ()->getClientScript()->registerCoreScript ('jquery'); 
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/jquery.fixedMenu.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/fancybox/jquery.fancybox-1.3.4.pack.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/fancybox/jquery.mousewheel-3.0.4.pack.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/Three.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Color.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vector2.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vector3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vector4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Ray.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Rectangle.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Matrix3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Matrix4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Object3D.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Quaternion.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vertex.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Face3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Face4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/UV.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Geometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Spline.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Edge.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/cameras/Camera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/Light.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/AmbientLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/DirectionalLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/PointLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/SpotLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/Material.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/LineBasicMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshBasicMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshLambertMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshPhongMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshDepthMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshNormalMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshFaceMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshShaderMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ParticleBasicMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ParticleCanvasMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ParticleDOMMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/textures/Texture.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/textures/DataTexture.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Particle.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/ParticleSystem.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Line.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Mesh.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Bone.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/SkinnedMesh.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Ribbon.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/LOD.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Sprite.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/scenes/Scene.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/scenes/Fog.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/scenes/FogExp2.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/Projector.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/DOMRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/CanvasRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/SVGRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLShaders.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLRenderTarget.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLRenderTargetCube.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableVertex.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableFace3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableFace4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableObject.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableParticle.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableLine.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/ColorUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/GeometryUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/ImageUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/SceneUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/ShaderUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/animation/AnimationHandler.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/animation/Animation.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/FirstPersonCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/PathCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/FlyCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/RollCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/TrackballCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/QuakeCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/Curve.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/CurvePath.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/Path.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/Shape.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/TextPath.js"); 
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/CubeGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/CylinderGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/ExtrudeGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/IcosahedronGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/LatheGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/PlaneGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/SphereGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/TextGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/TorusGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/TorusKnotGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/Loader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/JSONLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/BinaryLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/SceneLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/UTF8Loader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/objects/MarchingCubes.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/objects/Trident.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/physics/Collisions.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/physics/CollisionUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/renderers/AnaglyphWebGLRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/renderers/CrosseyedWebGLRenderer.js");

		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/RequestAnimationFrame.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs//fonts/helvetiker_regular.typeface.js");
		// $cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/Stats.js");
		?>
		<?php

/**
 * @param $action
 * @param boolean $ajax
 */
//init param
$ajax = isset ($ajax) ? $ajax : false;
$model = isset ($model) ? $model : new GoodsGeometryForm;
$labels = $model->attributeLabels(); 
$form=$this->beginWidget('CActiveForm', array(
	'id'=>'geometry-form',
	'action'=>array('webgl/saveGeometry/'), 
	'enableAjaxValidation'=>$ajax,
	'clientOptions'=>array('validateOnSubmit'=>true)
	
)); ?>

		<script>
	var container, stats;
	var camera, scene, renderer;
	var walking = true;
	var geo;
	init();
	animate();
	function init() {

		container = document.createElement('div');
		document.body.appendChild(container);

      var showWidth=300;
      var showHeight=220;
      
				camera = new THREE.Camera( 30, window.innerWidth/window.innerHeight, 1, 1000 );
				camera.position.y = 150;
				camera.position.z = 500;
				camera.target.position.y = 150;

		scene = new THREE.Scene();

		// Add the JS

		var aloader = new THREE.JSONLoader();
		aloader = new THREE.JSONLoader( );
	      		aloader.load( { model: "obj/female02/Female02_slim.js", callback: function( geometry ) {
      		    geo=geometry;			
      			zmesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
				// zmesh.position.x = start.x;
				// zmesh.position.z = 0;
				zmesh.position.y = 80;
				// zmesh.rotation.x=90*Math.PI / 180;
				zmesh.overdraw = true;
				zmesh.updateMatrix();
				scene.addObject(zmesh);
				// renderer.render( scene, camera );
      		}
      		});
		

		renderer = new THREE.WebGLRenderer();

		renderer.setSize(window.innerWidth, window.innerHeight);

		container.appendChild(renderer.domElement);

	}

	function animate() {
		requestAnimationFrame(animate);
		render();
		
	}

	function render() {

		// camera.lookAt(zmesh.position);
		renderer.render(scene, camera);

	}
	
	function save(){
		alert(geo);
	}
</script>
	
	<div>
		<?php echo $form->textField($model,'goodsName',array('class'=>'input','label'=>$labels['goodsName'],'autocomplete'=>'off')); ?>
 	</div>
	<div>
		<?php echo $form->textField($model,'geometry',array('class'=>'input','label'=>$labels['geometry'],'autocomplete'=>'off','value'=>'obj/female02/Female02_slim.js')); ?>
 	</div>
	<div>
		<?php echo $form->textField($model,'gTypeId',array('class'=>'input','label'=>$labels['gTypeId'],'autocomplete'=>'off')); ?>
 	</div>
 	<div>
		<?php echo $form->textField($model,'description',array('class'=>'input','label'=>$labels['description'],'autocomplete'=>'off')); ?>
 	</div>
 	<div>
		<?php echo $form->textField($model,'thumbPath',array('class'=>'input','label'=>$labels['thumbPath'],'autocomplete'=>'off')); ?>
 	</div> 	
	<?php echo CHtml::submitButton('上传',array('class'=>'button')); ?>
	</body>
	<?php $this->endWidget(); ?>
</html>
